package com.dly.file;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FileTest {
	
	public static void main(String[] args) throws IOException {
		
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH-MM-ss");
//		sdf.format(new Date());
		/*File file=new File("D:\\home\\a.txt");
		if(!file.exists()){
			file.createNewFile();
		}*/
		File file3=new File("D:/home");
		File file1=new File("D:/house/b.txt");
		if(!file1.exists()){
			file1.createNewFile();
			
		}
		File file4=new File("D:/house/a/b/c");
		if(!file4.exists()){
			file4.mkdirs();
		}
		
		/*File file2=file.getAbsoluteFile();
		String str=file.getAbsolutePath();
		System.out.println(file2);
		System.out.println(str);
		System.out.println(file.getCanonicalPath());*/
//		System.out.println(file.getFreeSpace());
		
//		System.out.println(file.lastModified());
		
		System.out.println(file1.length());//这个方法是打印文本内容的长度
		
//		String[] a = file3.list();
//		for(String b : a ){
//			System.out.println(b);
//		}
		
		File[] f=file3.listFiles();
		for(File ff:f){
			System.out.println(ff);
		}
		
//		System.out.println(file1.delete());//只删一个目录b.txt
		
		
		
//		File f=File.createTempFile("prefix", "suffix");
//		System.out.println(f);
		
//		System.out.println(file.compareTo(file1));
		f(file3);
		
	}
	public static void f(File file3){
		String[] a = file3.list();
		if(a.length>0){
			File[] ff= file3.listFiles();
			for(File f: ff ){
				
				System.out.println(f.getAbsolutePath());
				if(f.isDirectory()){
					f(f);
				}
				
			}
		}
		
	}
	
	
}
